summaryrefslogtreecommitdiff
path: root/nest/iface.c
diff options
context:
space:
mode:
Diffstat (limited to 'nest/iface.c')
-rw-r--r--nest/iface.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/nest/iface.c b/nest/iface.c
index 5f356fd8..186fbd90 100644
--- a/nest/iface.c
+++ b/nest/iface.c
@@ -12,6 +12,7 @@
#include "nest/iface.h"
#include "nest/protocol.h"
#include "lib/resource.h"
+#include "lib/string.h"
static pool *if_pool;
@@ -353,3 +354,44 @@ if_init(void)
neigh_slab = sl_new(if_pool, sizeof(neighbor));
init_list(&neigh_list);
}
+
+/*
+ * Interface Pattern Lists
+ */
+
+struct iface_patt *
+iface_patt_match(list *l, struct iface *i)
+{
+ struct iface_patt *p;
+
+ WALK_LIST(p, *l)
+ {
+ char *t = p->pattern;
+ int ok = 1;
+ if (*t == '-')
+ {
+ t++;
+ ok = 0;
+ }
+ if (patmatch(t, i->name))
+ return ok ? p : NULL;
+ }
+ return NULL;
+}
+
+int
+iface_patts_equal(list *a, list *b, int (*comp)(struct iface_patt *, struct iface_patt *))
+{
+ struct iface_patt *x, *y;
+
+ x = HEAD(*a);
+ y = HEAD(*b);
+ while (x->n.next && y->n.next)
+ {
+ if (strcmp(x->pattern, y->pattern) || comp && !comp(x, y))
+ return 0;
+ x = (void *) x->n.next;
+ y = (void *) y->n.next;
+ }
+ return (!x->n.next && !y->n.next);
+}