]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/ipfilter/lib/printmask.c
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / ipfilter / lib / printmask.c
1 /*      $FreeBSD$       */
2
3 /*
4  * Copyright (C) 2012 by Darren Reed.
5  *
6  * See the IPFILTER.LICENCE file for details on licencing.
7  *
8  * $Id$
9  */
10
11 #include "ipf.h"
12
13
14 void
15 printmask(family, mask)
16         int     family;
17         u_32_t  *mask;
18 {
19         struct in_addr ipa;
20         int ones;
21
22         if (family == AF_INET6) {
23                 PRINTF("/%d", count6bits(mask));
24         } else if ((ones = count4bits(*mask)) == -1) {
25                 ipa.s_addr = *mask;
26                 PRINTF("/%s", inet_ntoa(ipa));
27         } else {
28                 PRINTF("/%d", ones);
29         }
30 }