summaryrefslogtreecommitdiff
path: root/nest
diff options
context:
space:
mode:
Diffstat (limited to 'nest')
-rw-r--r--nest/route.h6
-rw-r--r--nest/rt-fib.c34
2 files changed, 40 insertions, 0 deletions
diff --git a/nest/route.h b/nest/route.h
index b927db5f..5421ece5 100644
--- a/nest/route.h
+++ b/nest/route.h
@@ -84,6 +84,8 @@ void fit_init(struct fib_iterator *, struct fib *); /* Internal functions, don't
struct fib_node *fit_get(struct fib *, struct fib_iterator *);
void fit_put(struct fib_iterator *, struct fib_node *);
void fit_put_next(struct fib *f, struct fib_iterator *i, struct fib_node *n, uint hpos);
+void fit_put_end(struct fib_iterator *i);
+void fit_copy(struct fib *f, struct fib_iterator *dst, struct fib_iterator *src);
#define FIB_WALK(fib, type, z) do { \
@@ -118,8 +120,12 @@ void fit_put_next(struct fib *f, struct fib_iterator *i, struct fib_node *n, uin
#define FIB_ITERATE_PUT_NEXT(it, fib) fit_put_next(fib, it, fn_, hpos_)
+#define FIB_ITERATE_PUT_END(it) fit_put_end(it)
+
#define FIB_ITERATE_UNLINK(it, fib) fit_get(fib, it)
+#define FIB_ITERATE_COPY(dst, src, fib) fit_copy(fib, dst, src)
+
/*
* Master Routing Tables. Generally speaking, each of them contains a FIB
diff --git a/nest/rt-fib.c b/nest/rt-fib.c
index 76a86e6e..a7f70371 100644
--- a/nest/rt-fib.c
+++ b/nest/rt-fib.c
@@ -584,6 +584,40 @@ found:
fit_put(i, n);
}
+void
+fit_put_end(struct fib_iterator *i)
+{
+ i->prev = i->next = NULL;
+ i->node = NULL;
+ i->hash = ~0 - 1;
+}
+
+void
+fit_copy(struct fib *f, struct fib_iterator *dst, struct fib_iterator *src)
+{
+ struct fib_iterator *nxt = src->next;
+
+ fit_get(f, dst);
+
+ if (!src->prev)
+ {
+ /* We are at the end */
+ fit_put_end(dst);
+ return;
+ }
+
+ src->next = dst;
+ dst->prev = src;
+
+ dst->next = nxt;
+ if (nxt)
+ nxt->prev = dst;
+
+ dst->node = src->node;
+ dst->hash = src->hash;
+}
+
+
#ifdef DEBUGGING
/**