From 5b7662dfe9883a7e44fa22ced316b437cc59aaeb Mon Sep 17 00:00:00 2001 From: mlaier Date: Fri, 2 Jun 2006 05:17:17 +0000 Subject: [PATCH] Print dynamic rules for IPv6 as well. PR: bin/98349 Submitted by: Mark Andrews MFC after: 2 weeks --- sbin/ipfw/ipfw2.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c index 36c3282eb963..ddaf4ac8ae5e 100644 --- a/sbin/ipfw/ipfw2.c +++ b/sbin/ipfw/ipfw2.c @@ -1965,6 +1965,7 @@ show_dyn_ipfw(ipfw_dyn_rule *d, int pcwidth, int bcwidth) struct protoent *pe; struct in_addr a; uint16_t rulenum; + char buf[INET6_ADDRSTRLEN]; if (!do_expired) { if (!d->expire && !(d->dyn_type == O_LIMIT_PARENT)) @@ -1993,11 +1994,20 @@ show_dyn_ipfw(ipfw_dyn_rule *d, int pcwidth, int bcwidth) else printf(" proto %u", d->id.proto); - a.s_addr = htonl(d->id.src_ip); - printf(" %s %d", inet_ntoa(a), d->id.src_port); + if (d->id.addr_type == 4) { + a.s_addr = htonl(d->id.src_ip); + printf(" %s %d", inet_ntoa(a), d->id.src_port); - a.s_addr = htonl(d->id.dst_ip); - printf(" <-> %s %d", inet_ntoa(a), d->id.dst_port); + a.s_addr = htonl(d->id.dst_ip); + printf(" <-> %s %d", inet_ntoa(a), d->id.dst_port); + } else if (d->id.addr_type == 6) { + printf(" %s %d", inet_ntop(AF_INET6, &d->id.src_ip6, buf, + sizeof(buf)), d->id.src_port); + printf(" <-> %s %d", inet_ntop(AF_INET6, &d->id.dst_ip6, buf, + sizeof(buf)), d->id.dst_port); + } else + printf(" UNKNOWN <-> UNKNOWN\n"); + printf("\n"); }