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#pragma ident "%Z%%M% %I% %E% SMI" 13 14#include "ipf.h" 15 16 17void printhostmask(v, addr, mask) 18int v; 19u_32_t *addr, *mask; 20{ 21#ifdef USE_INET6 22 char ipbuf[INET6_ADDRSTRLEN]; 23#else 24 struct in_addr ipa; 25#endif 26 27 if ((v == 4) && (!*addr) && (!*mask)) 28 printf("any"); 29 else { 30#ifdef USE_INET6 31 void *ptr = addr; 32 int af; 33 34 if (v == 4) 35 af = AF_INET; 36 else if (v == 6) 37 af = AF_INET6; 38 else 39 af = 0; 40 printf("%s", inet_ntop(af, ptr, ipbuf, sizeof(ipbuf))); 41#else 42 ipa.s_addr = *addr; 43 printf("%s", inet_ntoa(ipa)); 44#endif 45 if (mask != NULL) 46 printmask(v, mask); 47 } 48} 49