From: Egervary Gergely Date: Fri, 9 Dec 2016 00:49:36 +0000 (+1300) Subject: Support IPv6 NAT with PF for NetBSD and FreeBSD X-Git-Tag: SQUID_4_0_17~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a912913067c2d82b28f1d92bf71750500cbc0538;p=thirdparty%2Fsquid.git Support IPv6 NAT with PF for NetBSD and FreeBSD --- diff --git a/src/ip/Intercept.cc b/src/ip/Intercept.cc index 37d7c69bec..c52b72a77c 100644 --- a/src/ip/Intercept.cc +++ b/src/ip/Intercept.cc @@ -343,13 +343,20 @@ Ip::Intercept::PfInterception(const Comm::ConnectionPointer &newConn, int silent } memset(&nl, 0, sizeof(struct pfioc_natlook)); - newConn->remote.getInAddr(nl.saddr.v4); - nl.sport = htons(newConn->remote.port()); - newConn->local.getInAddr(nl.daddr.v4); + if (newConn->remote.isIPv6()) { + newConn->remote.getInAddr(nl.saddr.v6); + newConn->local.getInAddr(nl.daddr.v6); + nl.af = AF_INET6; + } else { + newConn->remote.getInAddr(nl.saddr.v4); + newConn->local.getInAddr(nl.daddr.v4); + nl.af = AF_INET; + } + + nl.sport = htons(newConn->remote.port()); nl.dport = htons(newConn->local.port()); - nl.af = AF_INET; nl.proto = IPPROTO_TCP; nl.direction = PF_OUT; @@ -366,7 +373,10 @@ Ip::Intercept::PfInterception(const Comm::ConnectionPointer &newConn, int silent debugs(89, 9, HERE << "address: " << newConn); return false; } else { - newConn->local = nl.rdaddr.v4; + if (newConn->remote.isIPv6()) + newConn->local = nl.rdaddr.v6; + else + newConn->local = nl.rdaddr.v4; newConn->local.port(ntohs(nl.rdport)); debugs(89, 5, HERE << "address NAT: " << newConn); return true;