summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2008-12-30 22:29:55 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2008-12-30 22:29:55 +0000
commit8c28a4cb8e30bae82e21dab411a0e4620cefe184 (patch)
tree42f2de04ff68f074ebbfa67fd693e13e1d44289e /usr.sbin
parent25fa8bd7a2eee31f87a5565144db1cccf5b728d3 (diff)
Correctly encode the IPv6 prefix. Only (prefixlen + 31)/32 * 4 bytes are
attached to the LSA (saves 8 to 12 bytes per prefix and makes our life more interesting or complex).
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ospf6d/ospf6.h7
-rw-r--r--usr.sbin/ospf6d/ospfe.c5
2 files changed, 8 insertions, 4 deletions
diff --git a/usr.sbin/ospf6d/ospf6.h b/usr.sbin/ospf6d/ospf6.h
index 7c5eba3bde2..0987540f2d3 100644
--- a/usr.sbin/ospf6d/ospf6.h
+++ b/usr.sbin/ospf6d/ospf6.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospf6.h,v 1.12 2008/12/30 21:31:54 claudio Exp $ */
+/* $OpenBSD: ospf6.h,v 1.13 2008/12/30 22:29:54 claudio Exp $ */
/*
* Copyright (c) 2004, 2005, 2007 Esben Norby <norby@openbsd.org>
@@ -203,11 +203,14 @@ struct ls_upd_hdr {
#define OSPF_PREFIX_P 0x08
#define OSPF_PREFIX_DN 0x10
+/* return encoded IPv6 prefix size in bytes depending on the prefixlen */
+#define LSA_PREFIXSIZE(x) (((x) + 31)/32 * 4)
+
struct lsa_prefix {
u_int8_t prefixlen;
u_int8_t options;
u_int16_t metric;
- struct in6_addr prefix;
+ /* + an IPv6 prefix encoded in (prefixlen + 31)/32 words */
};
struct lsa_rtr {
diff --git a/usr.sbin/ospf6d/ospfe.c b/usr.sbin/ospf6d/ospfe.c
index 7d611ccab4f..287c0b51c2d 100644
--- a/usr.sbin/ospf6d/ospfe.c
+++ b/usr.sbin/ospf6d/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.13 2008/12/30 21:44:18 claudio Exp $ */
+/* $OpenBSD: ospfe.c,v 1.14 2008/12/30 22:29:54 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -1030,10 +1030,11 @@ orig_link_lsa(struct iface *iface)
lsa_prefix.options = 0;
lsa_prefix.metric = 0;
inet6applymask(&prefix, &ia->addr, ia->prefixlen);
- lsa_prefix.prefix = prefix;
log_debug("orig_link_lsa: prefix %s", log_in6addr(&prefix));
if (buf_add(buf, &lsa_prefix, sizeof(lsa_prefix)))
fatal("orig_link_lsa: buf_add failed");
+ if (buf_add(buf, &prefix, LSA_PREFIXSIZE(ia->prefixlen)))
+ fatal("orig_link_lsa: buf_add failed");
num_prefix++;
}