summaryrefslogtreecommitdiffstats
path: root/nest/iface.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2009-05-06 22:02:45 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2009-05-06 22:02:45 +0200
commit20e94fb85b7097b57089e3912475ac881fd5528d (patch)
tree0f85803ddd2d27440bc177887127000963103705 /nest/iface.c
parent10ab65a8c9eb846655feacd22c29747743a65328 (diff)
downloadbird-20e94fb85b7097b57089e3912475ac881fd5528d.tar
bird-20e94fb85b7097b57089e3912475ac881fd5528d.zip
A change in OSPF and RIP interface patterns.
Allows to add more interface patterns to one common 'options' section like: interface "eth3", "eth4" { options common to eth3 and eth4 }; Also removes undocumented and unnecessary ability to specify more interface patterns with different 'options' sections: interface "eth3" { options ... }, "eth4" { options ... };
Diffstat (limited to 'nest/iface.c')
-rw-r--r--nest/iface.c67
1 files changed, 51 insertions, 16 deletions
diff --git a/nest/iface.c b/nest/iface.c
index 157a977..01f2581 100644
--- a/nest/iface.c
+++ b/nest/iface.c
@@ -543,32 +543,72 @@ if_init(void)
* Interface Pattern Lists
*/
-struct iface_patt *
-iface_patt_match(list *l, struct iface *i)
+static int
+iface_patt_match(struct iface_patt *ifp, struct iface *i)
{
- struct iface_patt *p;
+ struct iface_patt_node *p;
- WALK_LIST(p, *l)
+ WALK_LIST(p, ifp->ipn_list)
{
char *t = p->pattern;
- int ok = 1;
+ int pos = p->positive;
+
if (t)
{
if (*t == '-')
{
t++;
- ok = 0;
+ pos = !pos;
}
+
if (!patmatch(t, i->name))
continue;
}
- if (!i->addr || !ipa_in_net(i->addr->ip, p->prefix, p->pxlen))
- continue;
- return ok ? p : NULL;
+
+ if (p->pxlen)
+ if (!i->addr || !ipa_in_net(i->addr->ip, p->prefix, p->pxlen))
+ continue;
+
+ return pos;
}
+
+ return 0;
+}
+
+struct iface_patt *
+iface_patt_find(list *l, struct iface *i)
+{
+ struct iface_patt *p;
+
+ WALK_LIST(p, *l)
+ if (iface_patt_match(p, i))
+ return p;
+
return NULL;
}
+static int
+iface_plists_equal(struct iface_patt *pa, struct iface_patt *pb)
+{
+ struct iface_patt_node *x, *y;
+
+ x = HEAD(pa->ipn_list);
+ y = HEAD(pb->ipn_list);
+ while (x->n.next && y->n.next)
+ {
+ if ((x->positive != y->positive) ||
+ (!x->pattern && y->pattern) || /* This nasty lines where written by me... :-( Feela */
+ (!y->pattern && x->pattern) ||
+ ((x->pattern != y->pattern) && strcmp(x->pattern, y->pattern)) ||
+ !ipa_equal(x->prefix, y->prefix) ||
+ (x->pxlen != y->pxlen))
+ return 0;
+ x = (void *) x->n.next;
+ y = (void *) y->n.next;
+ }
+ return (!x->n.next && !y->n.next);
+}
+
int
iface_patts_equal(list *a, list *b, int (*comp)(struct iface_patt *, struct iface_patt *))
{
@@ -578,13 +618,8 @@ iface_patts_equal(list *a, list *b, int (*comp)(struct iface_patt *, struct ifac
y = HEAD(*b);
while (x->n.next && y->n.next)
{
- if ((!x->pattern && y->pattern) || /* This nasty lines where written by me... :-( Feela */
- (!y->pattern && x->pattern) ||
- (!(x->pattern==y->pattern) &&
- strcmp(x->pattern, y->pattern)) ||
- !ipa_equal(x->prefix, y->prefix) ||
- x->pxlen != y->pxlen ||
- comp && !comp(x, y))
+ if (!iface_plists_equal(x, y) ||
+ (comp && !comp(x, y)))
return 0;
x = (void *) x->n.next;
y = (void *) y->n.next;