summaryrefslogtreecommitdiff
path: root/usr.sbin/ospf6d/rde_lsdb.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2008-12-30 22:24:35 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2008-12-30 22:24:35 +0000
commit25fa8bd7a2eee31f87a5565144db1cccf5b728d3 (patch)
treee6bd84ae2d29fe2fcc9ff2b8f8e6983f50b362ab /usr.sbin/ospf6d/rde_lsdb.c
parentccc5738037773079498b2f9de8284c40da27638a (diff)
lsa_get_prefix() needs to use something else then struct lsa_prefix to
store the prefix to because the onwire format has the prefix compressed and so struct lsa_prefix will no longer carry the prefix in it. Use rt_prefix instead which is the expanded and host-byte-order version of the former.
Diffstat (limited to 'usr.sbin/ospf6d/rde_lsdb.c')
-rw-r--r--usr.sbin/ospf6d/rde_lsdb.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/usr.sbin/ospf6d/rde_lsdb.c b/usr.sbin/ospf6d/rde_lsdb.c
index c200f69f809..2337e950a2b 100644
--- a/usr.sbin/ospf6d/rde_lsdb.c
+++ b/usr.sbin/ospf6d/rde_lsdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_lsdb.c,v 1.12 2008/12/30 21:31:54 claudio Exp $ */
+/* $OpenBSD: rde_lsdb.c,v 1.13 2008/12/30 22:24:34 claudio Exp $ */
/*
* Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org>
@@ -34,7 +34,7 @@ int lsa_intra_a_pref_check(struct lsa *, u_int16_t);
void lsa_timeout(int, short, void *);
void lsa_refresh(struct vertex *);
int lsa_equal(struct lsa *, struct lsa *);
-int lsa_get_prefix(void *, u_int16_t, struct lsa_prefix *);
+int lsa_get_prefix(void *, u_int16_t, struct rt_prefix *);
RB_GENERATE(lsa_tree, vertex, entry, lsa_compare)
@@ -822,26 +822,27 @@ lsa_equal(struct lsa *a, struct lsa *b)
}
int
-lsa_get_prefix(void *buf, u_int16_t len, struct lsa_prefix *p)
+lsa_get_prefix(void *buf, u_int16_t len, struct rt_prefix *p)
{
- u_int32_t *buf32 = buf;
- u_int32_t *addr = NULL;
- u_int8_t prefixlen;
+ struct lsa_prefix *lp = buf;
+ u_int32_t *buf32, *addr = NULL;
+ u_int8_t prefixlen;
- if (len < sizeof(u_int32_t))
+ if (len < sizeof(*lp))
return (-1);
- prefixlen = ntohl(*buf32) >> 24;
+ prefixlen = lp->prefixlen;
if (p) {
bzero(p, sizeof(*p));
- p->prefixlen = prefixlen;
- p->options = (ntohl(*buf32) >> 16) & 0xff;
- p->metric = *buf32 & 0xffff;
+ p->prefixlen = lp->prefixlen;
+ p->options = lp->options;
+ p->metric = ntohs(lp->metric);
addr = (u_int32_t *)&p->prefix;
}
- buf32++;
- len -= sizeof(u_int32_t);
+
+ buf32 = (u_int32_t *)(lp + 1);
+ len -= sizeof(*lp);
for (; ((prefixlen + 31) / 32) > 0; prefixlen -= 32) {
if (len < sizeof(u_int32_t))