]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/ipfilter/lib/printhostmask.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / ipfilter / lib / printhostmask.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 printhostmask(family, addr, mask)
16         int     family;
17         u_32_t  *addr, *mask;
18 {
19 #ifdef  USE_INET6
20         char ipbuf[64];
21 #else
22         struct in_addr ipa;
23 #endif
24
25         if ((family == -1) || ((!addr || !*addr) && (!mask || !*mask)))
26                 PRINTF("any");
27         else {
28                 void *ptr = addr;
29
30 #ifdef  USE_INET6
31                 PRINTF("%s", inet_ntop(family, ptr, ipbuf, sizeof(ipbuf)));
32 #else
33                 ipa.s_addr = *addr;
34                 PRINTF("%s", inet_ntoa(ipa));
35 #endif
36                 if (mask != NULL)
37                         printmask(family, mask);
38         }
39 }