10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * Copyright (C) 1993-2001 by Darren Reed. 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * See the IPFILTER.LICENCE file for details on licencing. 50Sstevel@tonic-gate * 60Sstevel@tonic-gate * $Id: printhostmask.c,v 1.8 2002/04/11 15:01:19 darrenr Exp $ 7*637Sml37995 * 8*637Sml37995 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 9*637Sml37995 * Use is subject to license terms. 100Sstevel@tonic-gate */ 110Sstevel@tonic-gate 12*637Sml37995 #pragma ident "%Z%%M% %I% %E% SMI" 13*637Sml37995 140Sstevel@tonic-gate #include "ipf.h" 150Sstevel@tonic-gate 160Sstevel@tonic-gate 170Sstevel@tonic-gate void printhostmask(v, addr, mask) 180Sstevel@tonic-gate int v; 190Sstevel@tonic-gate u_32_t *addr, *mask; 200Sstevel@tonic-gate { 210Sstevel@tonic-gate #ifdef USE_INET6 22*637Sml37995 char ipbuf[INET6_ADDRSTRLEN]; 230Sstevel@tonic-gate #else 240Sstevel@tonic-gate struct in_addr ipa; 250Sstevel@tonic-gate #endif 260Sstevel@tonic-gate 270Sstevel@tonic-gate if (!*addr && !*mask) 280Sstevel@tonic-gate printf("any"); 290Sstevel@tonic-gate else { 300Sstevel@tonic-gate #ifdef USE_INET6 310Sstevel@tonic-gate void *ptr = addr; 320Sstevel@tonic-gate int af; 330Sstevel@tonic-gate 340Sstevel@tonic-gate if (v == 4) { 350Sstevel@tonic-gate ptr = addr; 360Sstevel@tonic-gate af = AF_INET; 370Sstevel@tonic-gate } else if (v == 6) { 380Sstevel@tonic-gate ptr = addr; 390Sstevel@tonic-gate af = AF_INET6; 400Sstevel@tonic-gate } else 410Sstevel@tonic-gate af = 0; 420Sstevel@tonic-gate printf("%s", inet_ntop(af, ptr, ipbuf, sizeof(ipbuf))); 430Sstevel@tonic-gate #else 440Sstevel@tonic-gate ipa.s_addr = *addr; 450Sstevel@tonic-gate printf("%s", inet_ntoa(ipa)); 460Sstevel@tonic-gate #endif 47*637Sml37995 printmask(v, mask); 480Sstevel@tonic-gate } 490Sstevel@tonic-gate } 50