mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-11 23:53:49 +00:00
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:
parent
f38a471c6f
commit
8708b74fd3
@ -126,7 +126,7 @@ community_list_insert (struct community_list_handler *ch,
|
||||
|
||||
/* Lookup community-list master. */
|
||||
cm = community_list_master_lookup (ch, style);
|
||||
if (! cm)
|
||||
if (!cm)
|
||||
return NULL;
|
||||
|
||||
/* Allocate new community_list and copy given name. */
|
||||
@ -214,11 +214,11 @@ community_list_lookup (struct community_list_handler *ch,
|
||||
struct community_list *list;
|
||||
struct community_list_master *cm;
|
||||
|
||||
if (! name)
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
cm = community_list_master_lookup (ch, style);
|
||||
if (! cm)
|
||||
if (!cm)
|
||||
return NULL;
|
||||
|
||||
for (list = cm->num.head; list; list = list->next)
|
||||
@ -237,7 +237,7 @@ community_list_get (struct community_list_handler *ch, char *name, int style)
|
||||
struct community_list *list;
|
||||
|
||||
list = community_list_lookup (ch, name, style);
|
||||
if (! list)
|
||||
if (!list)
|
||||
list = community_list_insert (ch, name, style);
|
||||
return list;
|
||||
}
|
||||
@ -345,7 +345,7 @@ community_list_entry_lookup (struct community_list *list, void *arg,
|
||||
/* Internal function to perform regular expression match for community
|
||||
attribute. */
|
||||
static int
|
||||
community_regexp_match (struct community *com, regex_t *reg)
|
||||
community_regexp_match (struct community *com, regex_t * reg)
|
||||
{
|
||||
char *str;
|
||||
|
||||
@ -364,10 +364,30 @@ 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 *
|
||||
community_regexp_delete (struct community *com, regex_t *reg)
|
||||
community_regexp_delete (struct community *com, regex_t * reg)
|
||||
{
|
||||
int i;
|
||||
u_int32_t comval;
|
||||
@ -375,7 +395,7 @@ community_regexp_delete (struct community *com, regex_t *reg)
|
||||
char c[12];
|
||||
char *str;
|
||||
|
||||
if (! com)
|
||||
if (!com)
|
||||
return NULL;
|
||||
|
||||
i = 0;
|
||||
@ -441,10 +461,35 @@ 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
|
||||
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;
|
||||
|
||||
@ -470,7 +515,7 @@ community_list_exact_match (struct community *com, struct community_list *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Delete all permitted communities in the list from com1 */
|
||||
/* Delete all permitted communities in the list from com. */
|
||||
struct community *
|
||||
community_list_match_delete (struct community *com,
|
||||
struct community_list *list)
|
||||
@ -565,7 +610,7 @@ community_list_set (struct community_list_handler *ch,
|
||||
/* When community-list already has entry, new entry should have same
|
||||
style. If you want to have mixed style community-list, you can
|
||||
comment out this check. */
|
||||
if (! community_list_empty_p (list))
|
||||
if (!community_list_empty_p (list))
|
||||
{
|
||||
struct community_entry *first;
|
||||
|
||||
@ -582,7 +627,7 @@ community_list_set (struct community_list_handler *ch,
|
||||
}
|
||||
|
||||
/* When str is NULL, it is matches any. */
|
||||
if (! str)
|
||||
if (!str)
|
||||
{
|
||||
entry = community_entry_new ();
|
||||
entry->direct = direct;
|
||||
@ -616,7 +661,7 @@ community_list_set (struct community_list_handler *ch,
|
||||
|
||||
/* Expanded community-list parse. String may include regular
|
||||
expression. */
|
||||
if (! entry && (style == COMMUNITY_LIST_EXPANDED
|
||||
if (!entry && (style == COMMUNITY_LIST_EXPANDED
|
||||
|| style == COMMUNITY_LIST_AUTO))
|
||||
{
|
||||
regex = bgp_regcomp (str);
|
||||
@ -661,7 +706,7 @@ community_list_unset (struct community_list_handler *ch,
|
||||
return COMMUNITY_LIST_ERR_CANT_FIND_LIST;
|
||||
|
||||
/* Delete all of entry belongs to this community-list. */
|
||||
if (! str)
|
||||
if (!str)
|
||||
{
|
||||
community_list_delete (list);
|
||||
return 0;
|
||||
@ -686,7 +731,7 @@ community_list_unset (struct community_list_handler *ch,
|
||||
|
||||
/* Expanded community-list parse. String may include regular
|
||||
expression. */
|
||||
if (! entry
|
||||
if (!entry
|
||||
&& (style == COMMUNITY_LIST_EXPANDED || style == COMMUNITY_LIST_AUTO))
|
||||
{
|
||||
regex = bgp_regcomp (str);
|
||||
@ -699,7 +744,7 @@ community_list_unset (struct community_list_handler *ch,
|
||||
return COMMUNITY_LIST_ERR_MALFORMED_VAL;
|
||||
}
|
||||
|
||||
if (! entry)
|
||||
if (!entry)
|
||||
return COMMUNITY_LIST_ERR_CANT_FIND_LIST;
|
||||
|
||||
community_list_entry_delete (list, entry, style);
|
||||
@ -725,7 +770,7 @@ extcommunity_list_set (struct community_list_handler *ch,
|
||||
/* When community-list already has entry, new entry should have same
|
||||
style. If you want to have mixed style community-list, you can
|
||||
comment out this check. */
|
||||
if (! community_list_empty_p (list))
|
||||
if (!community_list_empty_p (list))
|
||||
{
|
||||
struct community_entry *first;
|
||||
|
||||
@ -742,7 +787,7 @@ extcommunity_list_set (struct community_list_handler *ch,
|
||||
}
|
||||
|
||||
/* When str is NULL, it is matches any. */
|
||||
if (! str)
|
||||
if (!str)
|
||||
{
|
||||
entry = community_entry_new ();
|
||||
entry->direct = direct;
|
||||
@ -765,8 +810,10 @@ extcommunity_list_set (struct community_list_handler *ch,
|
||||
{
|
||||
entry = community_entry_new ();
|
||||
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->direct = direct;
|
||||
entry->style = EXTCOMMUNITY_LIST_STANDARD;
|
||||
@ -781,7 +828,7 @@ extcommunity_list_set (struct community_list_handler *ch,
|
||||
|
||||
/* Expanded extcommunity-list parse. String may include regular
|
||||
expression. */
|
||||
if (! entry && (style == EXTCOMMUNITY_LIST_EXPANDED
|
||||
if (!entry && (style == EXTCOMMUNITY_LIST_EXPANDED
|
||||
|| style == EXTCOMMUNITY_LIST_AUTO))
|
||||
{
|
||||
regex = bgp_regcomp (str);
|
||||
@ -826,7 +873,7 @@ extcommunity_list_unset (struct community_list_handler *ch,
|
||||
return COMMUNITY_LIST_ERR_CANT_FIND_LIST;
|
||||
|
||||
/* Delete all of entry belongs to this extcommunity-list. */
|
||||
if (! str)
|
||||
if (!str)
|
||||
{
|
||||
community_list_delete (list);
|
||||
return 0;
|
||||
@ -851,7 +898,7 @@ extcommunity_list_unset (struct community_list_handler *ch,
|
||||
|
||||
/* Expanded community-list parse. String may include regular
|
||||
expression. */
|
||||
if (! entry
|
||||
if (!entry
|
||||
&& (style == COMMUNITY_LIST_EXPANDED || style == COMMUNITY_LIST_AUTO))
|
||||
{
|
||||
regex = bgp_regcomp (str);
|
||||
@ -864,7 +911,7 @@ extcommunity_list_unset (struct community_list_handler *ch,
|
||||
return COMMUNITY_LIST_ERR_MALFORMED_VAL;
|
||||
}
|
||||
|
||||
if (! entry)
|
||||
if (!entry)
|
||||
return COMMUNITY_LIST_ERR_CANT_FIND_LIST;
|
||||
|
||||
community_list_entry_delete (list, entry, style);
|
||||
|
Loading…
Reference in New Issue
Block a user