summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2008-08-22 00:35:09 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2008-08-22 00:35:09 +0000
commit347683e58165eca28a35d2e716eef3d5e7835a97 (patch)
treed18eb18a2a6d66cf4021c694f5af83893d988b4d /sys
parent71eb026afc1294f921fa61b5b714b8b41bfe9993 (diff)
Make pf_print_host() print IPv6 addresses correctly.
ok mpf
Diffstat (limited to 'sys')
-rw-r--r--sys/net/pf.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/sys/net/pf.c b/sys/net/pf.c
index 0650e422cd2..1cbe62743d4 100644
--- a/sys/net/pf.c
+++ b/sys/net/pf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf.c,v 1.614 2008/08/02 12:34:37 henning Exp $ */
+/* $OpenBSD: pf.c,v 1.615 2008/08/22 00:35:08 bluhm Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -1189,34 +1189,33 @@ pf_print_host(struct pf_addr *addr, u_int16_t p, sa_family_t af)
#ifdef INET6
case AF_INET6: {
u_int16_t b;
- u_int8_t i, curstart = 255, curend = 0,
- maxstart = 0, maxend = 0;
+ u_int8_t i, curstart, curend, maxstart, maxend;
+ curstart = curend = maxstart = maxend = 255;
for (i = 0; i < 8; i++) {
if (!addr->addr16[i]) {
if (curstart == 255)
curstart = i;
- else
- curend = i;
+ curend = i;
} else {
- if (curstart) {
- if ((curend - curstart) >
- (maxend - maxstart)) {
- maxstart = curstart;
- maxend = curend;
- curstart = 255;
- }
+ if ((curend - curstart) >
+ (maxend - maxstart)) {
+ maxstart = curstart;
+ maxend = curend;
}
+ curstart = curend = 255;
}
}
+ if ((curend - curstart) >
+ (maxend - maxstart)) {
+ maxstart = curstart;
+ maxend = curend;
+ }
for (i = 0; i < 8; i++) {
if (i >= maxstart && i <= maxend) {
- if (maxend != 7) {
- if (i == maxstart)
- printf(":");
- } else {
- if (i == maxend)
- printf(":");
- }
+ if (i == 0)
+ printf(":");
+ if (i == maxend)
+ printf(":");
} else {
b = ntohs(addr->addr16[i]);
printf("%x", b);