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