diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-07-14 17:09:14 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-07-14 17:09:14 +0000 |
commit | a14ac56b2f66a98bde43a1dceb954bab8ebf393e (patch) | |
tree | bcad1f9a1437049a9ae153aa963fba825a2dd46e /usr.sbin/ospf6d | |
parent | 5df119a82f7df62d451b05c70ccdfbc73f6f8abc (diff) |
Another hand knitted offsetof() that needs to die. This time steal the
mask2prefixlen6 version from bgpd.
Diffstat (limited to 'usr.sbin/ospf6d')
-rw-r--r-- | usr.sbin/ospf6d/kroute.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.sbin/ospf6d/kroute.c b/usr.sbin/ospf6d/kroute.c index 5debe86d37e..e8738e36764 100644 --- a/usr.sbin/ospf6d/kroute.c +++ b/usr.sbin/ospf6d/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.26 2010/07/12 14:35:13 bluhm Exp $ */ +/* $OpenBSD: kroute.c,v 1.27 2010/07/14 17:09:13 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -696,17 +696,17 @@ protect_lo(void) u_int8_t mask2prefixlen(struct sockaddr_in6 *sa_in6) { - u_int8_t l = 0, i, len; + u_int8_t l = 0, *ap, *ep; /* * sin6_len is the size of the sockaddr so substract the offset of * the possibly truncated sin6_addr struct. */ - len = sa_in6->sin6_len - - (u_int8_t)(&((struct sockaddr_in6 *)NULL)->sin6_addr); - for (i = 0; i < len; i++) { + ap = (u_int8_t *)&sa_in6->sin6_addr; + ep = (u_int8_t *)sa_in6 + sa_in6->sin6_len; + for (; ap < ep; ap++) { /* this "beauty" is adopted from sbin/route/show.c ... */ - switch (sa_in6->sin6_addr.s6_addr[i]) { + switch (*ap) { case 0xff: l += 8; break; |