1 /* 2 * Copyright (C) 2000-2005 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 * 6 * $Id: printhostmask.c,v 1.8 2002/04/11 15:01:19 darrenr Exp $ 7 * 8 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 9 * Use is subject to license terms. 10 */ 11 12 #include "ipf.h" 13 14 15 void printhostmask(v, addr, mask) 16 int v; 17 u_32_t *addr, *mask; 18 { 19 #ifdef USE_INET6 20 char ipbuf[INET6_ADDRSTRLEN]; 21 #else 22 struct in_addr ipa; 23 #endif 24 25 if ((v == 4) && (!*addr) && (!*mask)) 26 printf("any"); 27 else { 28 #ifdef USE_INET6 29 void *ptr = addr; 30 int af; 31 32 if (v == 4) 33 af = AF_INET; 34 else if (v == 6) 35 af = AF_INET6; 36 else 37 af = 0; 38 printf("%s", inet_ntop(af, ptr, ipbuf, sizeof(ipbuf))); 39 #else 40 ipa.s_addr = *addr; 41 printf("%s", inet_ntoa(ipa)); 42 #endif 43 if (mask != NULL) 44 printmask(v, mask); 45 } 46 } 47