diff options
author | paul <paul> | 2003-01-17 13:20:40 +0000 |
---|---|---|
committer | paul <paul> | 2003-01-17 13:20:40 +0000 |
commit | f2298cf6e89f2f2958282f45a523fe47a6fac369 (patch) | |
tree | 22e9066166c9ef5c1d0f1d839d4d9f5904466b83 /bgpd/bgp_clist.c | |
parent | 0f0c3059be0fc711fb5b98d3d9c0d6dcd84c3992 (diff) | |
download | quagga-zebra_org_20030117.tar.bz2 quagga-zebra_org_20030117.tar.xz |
Import of Zebra CVS 20020117-13:15zebra_org_20030117
Diffstat (limited to 'bgpd/bgp_clist.c')
-rw-r--r-- | bgpd/bgp_clist.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index 0b6a2e8c..4bf194e3 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -364,6 +364,26 @@ community_regexp_match (struct community *com, regex_t *reg) return 0; } +static int +ecommunity_regexp_match (struct ecommunity *ecom, regex_t *reg) +{ + char *str; + + /* When there is no communities attribute it is treated as empty + string. */ + if (ecom == NULL || ecom->size == 0) + str = ""; + else + str = ecommunity_str (ecom); + + /* Regular expression match. */ + if (regexec (reg, str, 0, NULL, 0) == 0) + return 1; + + /* No match. */ + return 0; +} + /* Delete community attribute using regular expression match. Return modified communites attribute. */ static struct community * @@ -441,6 +461,30 @@ community_list_match (struct community *com, struct community_list *list) return 0; } +int +ecommunity_list_match (struct ecommunity *ecom, struct community_list *list) +{ + struct community_entry *entry; + + for (entry = list->head; entry; entry = entry->next) + { + if (entry->any) + return entry->direct == COMMUNITY_PERMIT ? 1 : 0; + + if (entry->style == EXTCOMMUNITY_LIST_STANDARD) + { + if (ecommunity_match (ecom, entry->u.ecom)) + return entry->direct == COMMUNITY_PERMIT ? 1 : 0; + } + else if (entry->style == EXTCOMMUNITY_LIST_EXPANDED) + { + if (ecommunity_regexp_match (ecom, entry->reg)) + return entry->direct == COMMUNITY_PERMIT ? 1 : 0; + } + } + return 0; +} + /* Perform exact matching. In case of expanded community-list, do same thing as community_list_match(). */ int |