diff options
author | 2008-08-22 00:35:08 +0000 | |
---|---|---|
committer | 2008-08-22 00:35:08 +0000 | |
commit | 708900713e13a80a861d494828d5ad0afa4cbebc (patch) | |
tree | 06224bb138ab52ad7c56275d7cabc31c02c2079a | |
parent | Assign the ip and ip6 pointers in ipsp_process_packet() only if a (diff) | |
download | wireguard-openbsd-708900713e13a80a861d494828d5ad0afa4cbebc.tar.xz wireguard-openbsd-708900713e13a80a861d494828d5ad0afa4cbebc.zip |
Make pf_print_host() print IPv6 addresses correctly.
ok mpf
-rw-r--r-- | sys/net/pf.c | 37 |
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); |