Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / cmd / ipf / lib / common / nat_setgroupmap.c
blob3c5b9a67ca249fbd5b0abef28c5b0bddd18b188b
1 /*
2 * Copyright (C) 1993-2001 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
7 * Use is subject to license terms.
8 */
10 #pragma ident "%Z%%M% %I% %E% SMI"
12 #include "ipf.h"
14 void nat_setgroupmap(n)
15 ipnat_t *n;
17 if (n->in_outmsk == n->in_inmsk)
18 n->in_ippip = 1;
19 else if (n->in_flags & IPN_AUTOPORTMAP) {
20 n->in_ippip = ~ntohl(n->in_inmsk);
21 if (n->in_outmsk != 0xffffffff)
22 n->in_ippip /= (~ntohl(n->in_outmsk) + 1);
23 n->in_ippip++;
24 if (n->in_ippip == 0)
25 n->in_ippip = 1;
26 n->in_ppip = USABLE_PORTS / n->in_ippip;
27 } else {
28 n->in_space = USABLE_PORTS * ~ntohl(n->in_outmsk);
29 n->in_nip = 0;
30 if (!(n->in_ppip = n->in_pmin))
31 n->in_ppip = 1;
32 n->in_ippip = USABLE_PORTS / n->in_ppip;