summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2004-06-25 18:48:19 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2004-06-25 18:48:19 +0000
commitc4ff37845d2dc781abd98949c836ff74f53cfa85 (patch)
tree80c618624cd95efca7ae67d0efd550c6f32b3c86 /usr.sbin
parentdb01f12fc2b03e122f1fe178593a503773f360c5 (diff)
after writing and deleting the kroute6 tree related functions for at least 5
times I am getting this in now sow I don't do it a 7th time...
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/kroute.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c
index 07a152c78ac..30d75a9c421 100644
--- a/usr.sbin/bgpd/kroute.c
+++ b/usr.sbin/bgpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.98 2004/06/22 20:28:58 claudio Exp $ */
+/* $OpenBSD: kroute.c,v 1.99 2004/06/25 18:48:18 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -48,6 +48,11 @@ struct kroute_node {
struct kroute r;
};
+struct kroute6_node {
+ RB_ENTRY(kroute6_node) entry;
+ struct kroute6 r;
+};
+
struct knexthop_node {
RB_ENTRY(knexthop_node) entry;
struct bgpd_addr nexthop;
@@ -68,6 +73,7 @@ struct kif_node {
};
int kroute_compare(struct kroute_node *, struct kroute_node *);
+int kroute6_compare(struct kroute6_node *, struct kroute6_node *);
int knexthop_compare(struct knexthop_node *, struct knexthop_node *);
int kif_compare(struct kif_node *, struct kif_node *);
@@ -111,6 +117,10 @@ RB_HEAD(kroute_tree, kroute_node) kroute_tree, krt;
RB_PROTOTYPE(kroute_tree, kroute_node, entry, kroute_compare)
RB_GENERATE(kroute_tree, kroute_node, entry, kroute_compare)
+RB_HEAD(kroute6_tree, kroute6_node) kroute6_tree, krt6;
+RB_PROTOTYPE(kroute6_tree, kroute6_node, entry, kroute6_compare)
+RB_GENERATE(kroute6_tree, kroute6_node, entry, kroute6_compare)
+
RB_HEAD(knexthop_tree, knexthop_node) knexthop_tree, knt;
RB_PROTOTYPE(knexthop_tree, knexthop_node, entry, knexthop_compare)
RB_GENERATE(knexthop_tree, knexthop_node, entry, knexthop_compare)
@@ -389,6 +399,25 @@ kroute_compare(struct kroute_node *a, struct kroute_node *b)
}
int
+kroute6_compare(struct kroute6_node *a, struct kroute6_node *b)
+{
+ int i;
+
+ for (i = 0; i < 16; i++) {
+ if (a->r.prefix.s6_addr[i] < b->r.prefix.s6_addr[i])
+ return (-1);
+ if (a->r.prefix.s6_addr[i] > b->r.prefix.s6_addr[i])
+ return (1);
+ }
+
+ if (a->r.prefixlen < b->r.prefixlen)
+ return (-1);
+ if (a->r.prefixlen > b->r.prefixlen)
+ return (1);
+ return (0);
+}
+
+int
knexthop_compare(struct knexthop_node *a, struct knexthop_node *b)
{
u_int32_t r;