2003-06-07 Paul Jakma <paul@dishone.st>

* (bgp_clist.c): Run it through indent -nut (all indentation to
	   be spaced, get rid of mix of tabs and spaces)
This commit is contained in:
paul 2003-06-07 02:03:11 +00:00
parent f38a471c6f
commit 8708b74fd3

View File

@ -364,6 +364,26 @@ community_regexp_match (struct community *com, regex_t *reg)
return 0; 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 /* Delete community attribute using regular expression match. Return
modified communites attribute. */ modified communites attribute. */
static struct community * static struct community *
@ -441,10 +461,35 @@ community_list_match (struct community *com, struct community_list *list)
return 0; 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 /* Perform exact matching. In case of expanded community-list, do
same thing as community_list_match(). */ same thing as community_list_match(). */
int int
community_list_exact_match (struct community *com, struct community_list *list) community_list_exact_match (struct community *com,
struct community_list *list)
{ {
struct community_entry *entry; struct community_entry *entry;
@ -470,7 +515,7 @@ community_list_exact_match (struct community *com, struct community_list *list)
return 0; return 0;
} }
/* Delete all permitted communities in the list from com1 */ /* Delete all permitted communities in the list from com. */
struct community * struct community *
community_list_match_delete (struct community *com, community_list_match_delete (struct community *com,
struct community_list *list) struct community_list *list)
@ -765,8 +810,10 @@ extcommunity_list_set (struct community_list_handler *ch,
{ {
entry = community_entry_new (); entry = community_entry_new ();
entry->config entry->config
= ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_COMMUNITY_LIST); =
ecom->str = ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_DISPLAY); ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_COMMUNITY_LIST);
ecom->str =
ecommunity_ecom2str (ecom, ECOMMUNITY_FORMAT_DISPLAY);
entry->u.ecom = ecom; entry->u.ecom = ecom;
entry->direct = direct; entry->direct = direct;
entry->style = EXTCOMMUNITY_LIST_STANDARD; entry->style = EXTCOMMUNITY_LIST_STANDARD;