From 8edf2361f9c4bd745a1249db3f66dfc079dd2ca1 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 3 Aug 1999 19:30:49 +0000 Subject: Cleaned up handling of interface patterns: o Parsing of interface patterns moved to generic code, introduced this_ipatt which works similarly to this_iface. o Interface patterns now support selection by both interface names and primary IP addresses. o Proto `direct' updated. o RIP updated as well, it also seems the memory corruption bug there is gone. --- nest/iface.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'nest/iface.c') diff --git a/nest/iface.c b/nest/iface.c index 19ed7fb..3a5d9c6 100644 --- a/nest/iface.c +++ b/nest/iface.c @@ -588,13 +588,19 @@ iface_patt_match(list *l, struct iface *i) { char *t = p->pattern; int ok = 1; - if (*t == '-') + if (t) { - t++; - ok = 0; + if (*t == '-') + { + t++; + ok = 0; + } + if (!patmatch(t, i->name)) + continue; } - if (patmatch(t, i->name)) - return ok ? p : NULL; + if (!i->addr || !ipa_in_net(i->addr->ip, p->prefix, p->pxlen)) + continue; + return ok ? p : NULL; } return NULL; } @@ -608,7 +614,10 @@ 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 (strcmp(x->pattern, y->pattern) || comp && !comp(x, y)) + if (strcmp(x->pattern, y->pattern) || + !ipa_equal(x->prefix, y->prefix) || + x->pxlen != y->pxlen || + comp && !comp(x, y)) return 0; x = (void *) x->n.next; y = (void *) y->n.next; -- cgit v1.2.3