2005-04-25 18:20:15 +00:00
|
|
|
/* $FreeBSD$ */
|
2005-04-25 17:31:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 1993-2001 by Darren Reed.
|
|
|
|
*
|
|
|
|
* See the IPFILTER.LICENCE file for details on licencing.
|
|
|
|
*
|
2005-12-30 11:52:26 +00:00
|
|
|
* $Id: printhostmask.c,v 1.8 2002/04/11 15:01:19 darrenr Exp $
|
2005-04-25 17:31:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ipf.h"
|
|
|
|
|
|
|
|
|
|
|
|
void printhostmask(v, addr, mask)
|
|
|
|
int v;
|
|
|
|
u_32_t *addr, *mask;
|
|
|
|
{
|
|
|
|
#ifdef USE_INET6
|
|
|
|
char ipbuf[64];
|
|
|
|
#else
|
|
|
|
struct in_addr ipa;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!*addr && !*mask)
|
|
|
|
printf("any");
|
|
|
|
else {
|
|
|
|
#ifdef USE_INET6
|
|
|
|
void *ptr = addr;
|
|
|
|
int af;
|
|
|
|
|
|
|
|
if (v == 4) {
|
|
|
|
ptr = addr;
|
|
|
|
af = AF_INET;
|
|
|
|
} else if (v == 6) {
|
|
|
|
ptr = addr;
|
|
|
|
af = AF_INET6;
|
|
|
|
} else
|
|
|
|
af = 0;
|
|
|
|
printf("%s", inet_ntop(af, ptr, ipbuf, sizeof(ipbuf)));
|
|
|
|
#else
|
|
|
|
ipa.s_addr = *addr;
|
|
|
|
printf("%s", inet_ntoa(ipa));
|
|
|
|
#endif
|
|
|
|
printmask(mask);
|
|
|
|
}
|
|
|
|
}
|