1 2 /* 3 * Copyright (C) 2012 by Darren Reed. 4 * 5 * See the IPFILTER.LICENCE file for details on licencing. 6 */ 7 #if !defined(lint) 8 static const char rcsid[] = "@(#)$Id$"; 9 #endif 10 11 #include "ipf.h" 12 13 void 14 nat_setgroupmap(ipnat_t *n) 15 { 16 if (n->in_nsrcmsk == n->in_osrcmsk) 17 n->in_ippip = 1; 18 else if (n->in_flags & IPN_AUTOPORTMAP) { 19 n->in_ippip = ~ntohl(n->in_osrcmsk); 20 if (n->in_nsrcmsk != 0xffffffff) 21 n->in_ippip /= (~ntohl(n->in_nsrcmsk) + 1); 22 n->in_ippip++; 23 if (n->in_ippip == 0) 24 n->in_ippip = 1; 25 n->in_ppip = USABLE_PORTS / n->in_ippip; 26 } else { 27 n->in_space = USABLE_PORTS * ~ntohl(n->in_nsrcmsk); 28 n->in_snip = 0; 29 if (!(n->in_ppip = n->in_spmin)) 30 n->in_ppip = 1; 31 n->in_ippip = USABLE_PORTS / n->in_ppip; 32 } 33 } 34