Sync usage with man page.
[netbsd-mini2440.git] / dist / ipf / lib / fill6bits.c
bloba5c3f3572f6898670dea9ff69cc5cd1095019c13
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2000-2002 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
8 * Id: fill6bits.c,v 1.5.4.1 2006/06/16 17:20:58 darrenr Exp
9 */
11 #include "ipf.h"
14 void fill6bits(bits, msk)
15 int bits;
16 u_int *msk;
18 if (bits == 0) {
19 msk[0] = 0;
20 msk[1] = 0;
21 msk[2] = 0;
22 msk[3] = 0;
23 return;
26 msk[0] = 0xffffffff;
27 msk[1] = 0xffffffff;
28 msk[2] = 0xffffffff;
29 msk[3] = 0xffffffff;
31 if (bits == 128)
32 return;
33 if (bits > 96) {
34 msk[3] = htonl(msk[3] << (128 - bits));
35 } else if (bits > 64) {
36 msk[3] = 0;
37 msk[2] = htonl(msk[2] << (96 - bits));
38 } else if (bits > 32) {
39 msk[3] = 0;
40 msk[2] = 0;
41 msk[1] = htonl(msk[1] << (64 - bits));
42 } else {
43 msk[3] = 0;
44 msk[2] = 0;
45 msk[1] = 0;
46 msk[0] = htonl(msk[0] << (32 - bits));