diff options
author | kn <kn@cvs.openbsd.org> | 2018-09-06 14:46:37 +0000 |
---|---|---|
committer | kn <kn@cvs.openbsd.org> | 2018-09-06 14:46:37 +0000 |
commit | f5d4759e1e93811b5726e89786d109f80500255d (patch) | |
tree | 5836db30de5cca7a84f2aeab1ea22f34d42dc5ee /sbin | |
parent | cbf3a29fb4db966cda8b36c809c189bd039c6087 (diff) |
Fill netmask AF-independently in print_host()
Instead of masking the host address in two different ways, just fill it
no matter the address family. In case of AF_INET, setting the extra 96 bit
does not hurt.
While here, stop resetting `af' for no reason and move up the variable
declaration.
OK benno sashan
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/pfctl/pf_print_state.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/sbin/pfctl/pf_print_state.c b/sbin/pfctl/pf_print_state.c index f996f05661f..0516796c660 100644 --- a/sbin/pfctl/pf_print_state.c +++ b/sbin/pfctl/pf_print_state.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_print_state.c,v 1.65 2018/07/24 09:48:04 kn Exp $ */ +/* $OpenBSD: pf_print_state.c,v 1.66 2018/09/06 14:46:36 kn Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -166,8 +166,9 @@ void print_host(struct pf_addr *addr, u_int16_t port, sa_family_t af, u_int16_t rdom, const char *proto, int opts) { - struct servent *s = NULL; - char ps[6]; + struct pf_addr_wrap aw; + struct servent *s = NULL; + char ps[6]; if (rdom) printf("(%u) ", ntohs(rdom)); @@ -175,16 +176,9 @@ print_host(struct pf_addr *addr, u_int16_t port, sa_family_t af, u_int16_t rdom, if (opts & PF_OPT_USEDNS) print_name(addr, af); else { - struct pf_addr_wrap aw; - memset(&aw, 0, sizeof(aw)); aw.v.a.addr = *addr; - if (af == AF_INET) - aw.v.a.mask.addr32[0] = 0xffffffff; - else { - memset(&aw.v.a.mask, 0xff, sizeof(aw.v.a.mask)); - af = AF_INET6; - } + memset(&aw.v.a.mask, 0xff, sizeof(aw.v.a.mask)); print_addr(&aw, af, opts & PF_OPT_VERBOSE2); } |