141edb306SCy Schubert 241edb306SCy Schubert /* 341edb306SCy Schubert * Copyright (C) 2012 by Darren Reed. 441edb306SCy Schubert * 541edb306SCy Schubert * See the IPFILTER.LICENCE file for details on licencing. 641edb306SCy Schubert */ 741edb306SCy Schubert 841edb306SCy Schubert #include "ipf.h" 941edb306SCy Schubert 10*efeb8bffSCy Schubert void nat_setgroupmap(ipnat_t * n)11*efeb8bffSCy Schubertnat_setgroupmap(ipnat_t *n) 1241edb306SCy Schubert { 1341edb306SCy Schubert if (n->in_nsrcmsk == n->in_osrcmsk) 1441edb306SCy Schubert n->in_ippip = 1; 1541edb306SCy Schubert else if (n->in_flags & IPN_AUTOPORTMAP) { 1641edb306SCy Schubert n->in_ippip = ~ntohl(n->in_osrcmsk); 1741edb306SCy Schubert if (n->in_nsrcmsk != 0xffffffff) 1841edb306SCy Schubert n->in_ippip /= (~ntohl(n->in_nsrcmsk) + 1); 1941edb306SCy Schubert n->in_ippip++; 2041edb306SCy Schubert if (n->in_ippip == 0) 2141edb306SCy Schubert n->in_ippip = 1; 2241edb306SCy Schubert n->in_ppip = USABLE_PORTS / n->in_ippip; 2341edb306SCy Schubert } else { 2441edb306SCy Schubert n->in_space = USABLE_PORTS * ~ntohl(n->in_nsrcmsk); 2541edb306SCy Schubert n->in_snip = 0; 2641edb306SCy Schubert if (!(n->in_ppip = n->in_spmin)) 2741edb306SCy Schubert n->in_ppip = 1; 2841edb306SCy Schubert n->in_ippip = USABLE_PORTS / n->in_ppip; 2941edb306SCy Schubert } 3041edb306SCy Schubert } 31