141edb306SCy Schubert /* $FreeBSD$ */ 241edb306SCy Schubert 341edb306SCy Schubert /* 441edb306SCy Schubert * Copyright (C) 2012 by Darren Reed. 541edb306SCy Schubert * 641edb306SCy Schubert * See the IPFILTER.LICENCE file for details on licencing. 741edb306SCy Schubert * 841edb306SCy Schubert * $Id$ 941edb306SCy Schubert */ 1041edb306SCy Schubert 1141edb306SCy Schubert #include "ipf.h" 1241edb306SCy Schubert 1341edb306SCy Schubert 14*efeb8bffSCy Schubert int 15*efeb8bffSCy Schubert count6bits(u_32_t *msk) 1641edb306SCy Schubert { 1741edb306SCy Schubert int i = 0, k; 1841edb306SCy Schubert u_32_t j; 1941edb306SCy Schubert 2041edb306SCy Schubert for (k = 3; k >= 0; k--) 2141edb306SCy Schubert if (msk[k] == 0xffffffff) 2241edb306SCy Schubert i += 32; 2341edb306SCy Schubert else { 2441edb306SCy Schubert for (j = msk[k]; j; j <<= 1) 2541edb306SCy Schubert if (j & 0x80000000) 2641edb306SCy Schubert i++; 2741edb306SCy Schubert } 2841edb306SCy Schubert return i; 2941edb306SCy Schubert } 30