+
+ do
+ {
+ /* Go find subnet */
+
+ p = (subnet_t *)avl_search_closest_smaller(subnet_tree, &subnet);
+
+ /* Check if the found subnet REALLY matches */
+cp
+ if(p)
+ {
+ if ((*address & p->net.ipv4.mask) == p->net.ipv4.address)
+ break;
+ else
+ {
+ /* Otherwise, see if there is a bigger enclosing subnet */
+
+ subnet.net.ipv4.mask = p->net.ipv4.mask << 1;
+ subnet.net.ipv4.address &= subnet.net.ipv4.mask;
+ }
+ }
+ } while (p);
+
+ return p;