diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2008-12-30 22:24:35 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2008-12-30 22:24:35 +0000 |
commit | 25fa8bd7a2eee31f87a5565144db1cccf5b728d3 (patch) | |
tree | e6bd84ae2d29fe2fcc9ff2b8f8e6983f50b362ab /usr.sbin/ospf6d | |
parent | ccc5738037773079498b2f9de8284c40da27638a (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')
-rw-r--r-- | usr.sbin/ospf6d/rde.h | 10 | ||||
-rw-r--r-- | usr.sbin/ospf6d/rde_lsdb.c | 27 |
2 files changed, 23 insertions, 14 deletions
diff --git a/usr.sbin/ospf6d/rde.h b/usr.sbin/ospf6d/rde.h index c3b2e1b42f4..346b1a28dba 100644 --- a/usr.sbin/ospf6d/rde.h +++ b/usr.sbin/ospf6d/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.5 2007/11/27 12:23:06 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.6 2008/12/30 22:24:34 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -74,6 +74,14 @@ struct rde_nbr { int self; }; +/* expanded and host-byte-order version of a lsa_prefix */ +struct rt_prefix { + struct in6_addr prefix; + u_int16_t metric; + u_int8_t prefixlen; + u_int8_t options; +}; + struct rt_nexthop { TAILQ_ENTRY(rt_nexthop) entry; struct in6_addr nexthop; 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)) |