+bool_t subnets_intersect(struct subnet a, struct subnet b)
+{
+ uint32_t mask=a.mask&b.mask;
+ return ((a.prefix&mask)==(b.prefix&mask));
+}
+
+bool_t subnet_intersects_with_list(struct subnet a, struct subnet_list *b)
+{
+ uint32_t i;
+
+ for (i=0; i<b->entries; i++) {
+ if (subnets_intersect(a,b->list[i])) return True;
+ }
+ return False;
+}
+
+bool_t subnet_lists_intersect(struct subnet_list *a, struct subnet_list *b)
+{
+ uint32_t i;
+ for (i=0; i<a->entries; i++) {
+ if (subnet_intersects_with_list(a->list[i],b)) return True;
+ }
+ return False;
+}
+