------------------------------------------------------------ revno: 14120 revision-id: squid3@treenet.co.nz-20161209034636-wytrnx7ks2jv0sxt parent: squid3@treenet.co.nz-20161209015833-xm965d5l6u03qhew author: Egervary Gergely committer: Amos Jeffries branch nick: 3.5 timestamp: Fri 2016-12-09 16:46:36 +1300 message: Support IPv6 NAT with PF for NetBSD and FreeBSD ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20161209034636-wytrnx7ks2jv0sxt # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # testament_sha1: b47da8d30fe000bbe50ea978bab7594065f7dc07 # timestamp: 2016-12-09 03:51:01 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.5 # base_revision_id: squid3@treenet.co.nz-20161209015833-\ # xm965d5l6u03qhew # # Begin patch === modified file 'src/ip/Intercept.cc' --- src/ip/Intercept.cc 2016-10-25 08:25:30 +0000 +++ src/ip/Intercept.cc 2016-12-09 03:46:36 +0000 @@ -339,13 +339,20 @@ } memset(&nl, 0, sizeof(struct pfioc_natlook)); - newConn->remote.getInAddr(nl.saddr.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()); - - newConn->local.getInAddr(nl.daddr.v4); nl.dport = htons(newConn->local.port()); - nl.af = AF_INET; nl.proto = IPPROTO_TCP; nl.direction = PF_OUT; @@ -361,7 +368,10 @@ 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;