1 1.3 prlw1 /* $NetBSD: printhostmask.c,v 1.3 2014/12/20 13:15:48 prlw1 Exp $ */ 2 1.1 christos 3 1.1 christos /* 4 1.2 darrenr * Copyright (C) 2012 by Darren Reed. 5 1.1 christos * 6 1.1 christos * See the IPFILTER.LICENCE file for details on licencing. 7 1.1 christos * 8 1.2 darrenr * Id: printhostmask.c,v 1.1.1.2 2012/07/22 13:44:40 darrenr Exp $ 9 1.1 christos */ 10 1.1 christos 11 1.1 christos #include "ipf.h" 12 1.1 christos 13 1.1 christos 14 1.1 christos void 15 1.1 christos printhostmask(family, addr, mask) 16 1.1 christos int family; 17 1.1 christos u_32_t *addr, *mask; 18 1.1 christos { 19 1.1 christos #ifdef USE_INET6 20 1.1 christos char ipbuf[64]; 21 1.1 christos #else 22 1.1 christos struct in_addr ipa; 23 1.1 christos #endif 24 1.1 christos 25 1.1 christos if ((family == -1) || ((!addr || !*addr) && (!mask || !*mask))) 26 1.1 christos PRINTF("any"); 27 1.1 christos else { 28 1.3 prlw1 #ifdef USE_INET6 29 1.1 christos void *ptr = addr; 30 1.1 christos 31 1.1 christos PRINTF("%s", inet_ntop(family, ptr, ipbuf, sizeof(ipbuf))); 32 1.1 christos #else 33 1.1 christos ipa.s_addr = *addr; 34 1.1 christos PRINTF("%s", inet_ntoa(ipa)); 35 1.1 christos #endif 36 1.1 christos if (mask != NULL) 37 1.1 christos printmask(family, mask); 38 1.1 christos } 39 1.1 christos } 40