aboutsummaryrefslogtreecommitdiff
path: root/contrib/ipfilter/lib/printhashnode.c
blob: c22b7a74f87d921f31b4d11b5ebd1c80049b37ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*	$FreeBSD: src/contrib/ipfilter/lib/printhashnode.c,v 1.3.10.1.6.1 2010/12/21 17:09:25 kensmith Exp $	*/

/*
 * Copyright (C) 2002-2005 by Darren Reed.
 *
 * See the IPFILTER.LICENCE file for details on licencing.
 */

#include "ipf.h"

#define	PRINTF	(void)printf
#define	FPRINTF	(void)fprintf

iphtent_t *printhashnode(iph, ipep, copyfunc, opts)
iphtable_t *iph;
iphtent_t *ipep;
copyfunc_t copyfunc;
int opts;
{
	iphtent_t ipe;

	if ((*copyfunc)(ipep, &ipe, sizeof(ipe)))
		return NULL;

	ipe.ipe_addr.in4_addr = htonl(ipe.ipe_addr.in4_addr);
	ipe.ipe_mask.in4_addr = htonl(ipe.ipe_mask.in4_addr);

	if ((opts & OPT_DEBUG) != 0) {
		PRINTF("\tAddress: %s",
			inet_ntoa(ipe.ipe_addr.in4));
		printmask((u_32_t *)&ipe.ipe_mask.in4_addr);
		PRINTF("\tRef. Count: %d\tGroup: %s\n", ipe.ipe_ref,
			ipe.ipe_group);
	} else {
		putchar(' ');
		printip((u_32_t *)&ipe.ipe_addr.in4_addr);
		printmask((u_32_t *)&ipe.ipe_mask.in4_addr);
		if (ipe.ipe_value != 0) {
			switch (iph->iph_type & ~IPHASH_ANON)
			{
			case IPHASH_GROUPMAP :
				if (strncmp(ipe.ipe_group, iph->iph_name,
					    FR_GROUPLEN))
					PRINTF(", group = %s", ipe.ipe_group);
				break;
			}
		}
		putchar(';');
	}

	ipep = ipe.ipe_next;
	return ipep;
}