1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright (C) 1993-2001 by Darren Reed.
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * See the IPFILTER.LICENCE file for details on licencing.
5*7c478bd9Sstevel@tonic-gate  *
6*7c478bd9Sstevel@tonic-gate  * $Id: count6bits.c,v 1.4 2001/06/09 17:09:23 darrenr Exp $
7*7c478bd9Sstevel@tonic-gate  */
8*7c478bd9Sstevel@tonic-gate 
9*7c478bd9Sstevel@tonic-gate #include "ipf.h"
10*7c478bd9Sstevel@tonic-gate 
11*7c478bd9Sstevel@tonic-gate 
count6bits(msk)12*7c478bd9Sstevel@tonic-gate int count6bits(msk)
13*7c478bd9Sstevel@tonic-gate u_32_t *msk;
14*7c478bd9Sstevel@tonic-gate {
15*7c478bd9Sstevel@tonic-gate 	int i = 0, k;
16*7c478bd9Sstevel@tonic-gate 	u_32_t j;
17*7c478bd9Sstevel@tonic-gate 
18*7c478bd9Sstevel@tonic-gate 	for (k = 3; k >= 0; k--)
19*7c478bd9Sstevel@tonic-gate 		if (msk[k] == 0xffffffff)
20*7c478bd9Sstevel@tonic-gate 			i += 32;
21*7c478bd9Sstevel@tonic-gate 		else {
22*7c478bd9Sstevel@tonic-gate 			for (j = msk[k]; j; j <<= 1)
23*7c478bd9Sstevel@tonic-gate 				if (j & 0x80000000)
24*7c478bd9Sstevel@tonic-gate 					i++;
25*7c478bd9Sstevel@tonic-gate 		}
26*7c478bd9Sstevel@tonic-gate 	return i;
27*7c478bd9Sstevel@tonic-gate }
28