abd0900a99
4.1.34 - Release 11 March 2010
2964907 uninitialised use compile error
2959506 ipfstat does not display rules with compat
2949139 FR_T_BUILTIN masked out incorrectly
2937422
packets filtered with pools should not be cached
2935529 use of rules with tags leads to deadlock
2917501 whitespace cleanup required
2881514 in/out object functions not wired for compatibility
2841771 ipf/ippool rule maintenace bugs: memory leak, ref-counter bug
2839698 H.323 proxy does not clear fin_state/fin_nat
47 lines
703 B
C
47 lines
703 B
C
/* $NetBSD: ntomask.c,v 1.1.1.3 2010/04/17 20:45:58 darrenr Exp $ */
|
|
|
|
/*
|
|
* Copyright (C) 2002-2005 by Darren Reed.
|
|
*
|
|
* See the IPFILTER.LICENCE file for details on licencing.
|
|
*
|
|
* Id: ntomask.c,v 1.6.2.2 2009/12/27 06:58:06 darrenr Exp
|
|
*/
|
|
|
|
#include "ipf.h"
|
|
|
|
int ntomask(v, nbits, ap)
|
|
int v, nbits;
|
|
u_32_t *ap;
|
|
{
|
|
u_32_t mask;
|
|
|
|
if (nbits < 0)
|
|
return -1;
|
|
|
|
switch (v)
|
|
{
|
|
case 4 :
|
|
if (nbits > 32 || use_inet6 != 0)
|
|
return -1;
|
|
if (nbits == 0) {
|
|
mask = 0;
|
|
} else {
|
|
mask = 0xffffffff;
|
|
mask <<= (32 - nbits);
|
|
}
|
|
*ap = htonl(mask);
|
|
break;
|
|
|
|
case 6 :
|
|
if ((nbits > 128) || (use_inet6 == 0))
|
|
return -1;
|
|
fill6bits(nbits, ap);
|
|
break;
|
|
|
|
default :
|
|
return -1;
|
|
}
|
|
return 0;
|
|
}
|