summaryrefslogtreecommitdiff
path: root/nest/rt-fib.c
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2000-05-13 11:42:06 +0000
committerMartin Mares <mj@ucw.cz>2000-05-13 11:42:06 +0000
commit56d6c530eba46dde7280d6743fea7e750f2d5635 (patch)
tree07fdb990d0aab66c5313dee0d9e59c2b80cd3941 /nest/rt-fib.c
parentd3abfbc68d7f921b2547b39a6baa9bee6c89b78d (diff)
Added fib_route() which does (although very slow) lookup of longest-match
routing in a FIB.
Diffstat (limited to 'nest/rt-fib.c')
-rw-r--r--nest/rt-fib.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/nest/rt-fib.c b/nest/rt-fib.c
index 22ba2ff6..6a5d1361 100644
--- a/nest/rt-fib.c
+++ b/nest/rt-fib.c
@@ -152,6 +152,23 @@ fib_get(struct fib *f, ip_addr *a, int len)
return e;
}
+void *
+fib_route(struct fib *f, ip_addr a, int len)
+{
+ ip_addr a0;
+ void *t;
+
+ while (len >= 0)
+ {
+ a0 = ipa_and(a, ipa_mkmask(len));
+ t = fib_find(f, &a0, len);
+ if (t)
+ return t;
+ len--;
+ }
+ return NULL;
+}
+
static inline void
fib_merge_readers(struct fib_iterator *i, struct fib_node *to)
{