]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/ipfilter/lib/printhostmask.c
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / ipfilter / lib / printhostmask.c
1 /*      $FreeBSD$       */
2
3 /*
4  * Copyright (C) 2000-2005 by Darren Reed.
5  *
6  * See the IPFILTER.LICENCE file for details on licencing.
7  *
8  * $Id: printhostmask.c,v 1.8.4.1 2006/06/16 17:21:12 darrenr Exp $
9  */
10
11 #include "ipf.h"
12
13
14 void    printhostmask(v, addr, mask)
15 int     v;
16 u_32_t  *addr, *mask;
17 {
18 #ifdef  USE_INET6
19         char ipbuf[64];
20 #else
21         struct in_addr ipa;
22 #endif
23
24         if (!*addr && !*mask)
25                 printf("any");
26         else {
27 #ifdef  USE_INET6
28                 void *ptr = addr;
29                 int af;
30
31                 if (v == 4) {
32                         ptr = addr;
33                         af = AF_INET;
34                 } else if (v == 6) {
35                         ptr = addr;
36                         af = AF_INET6;
37                 } else
38                         af = 0;
39                 printf("%s", inet_ntop(af, ptr, ipbuf, sizeof(ipbuf)));
40 #else
41                 ipa.s_addr = *addr;
42                 printf("%s", inet_ntoa(ipa));
43 #endif
44                 printmask(mask);
45         }
46 }