aboutsummaryrefslogtreecommitdiff
path: root/contrib/ipfilter/lib/printaddr.c
blob: 03fbacbcce741d863b4a03e08d5d1caa55eb6f9d (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
 * Copyright (C) 2012 by Darren Reed.
 *
 * See the IPFILTER.LICENCE file for details on licencing.
 *
 * $Id$
 */

#include "ipf.h"

void
printaddr(family, type, base, ifidx, addr, mask)
	int family, type, ifidx;
	char *base;
	u_32_t *addr, *mask;
{
	char *suffix;

	switch (type)
	{
	case FRI_BROADCAST :
		suffix = "bcast";
		break;

	case FRI_DYNAMIC :
		PRINTF("%s", base + ifidx);
		printmask(family, mask);
		suffix = NULL;
		break;

	case FRI_NETWORK :
		suffix = "net";
		break;

	case FRI_NETMASKED :
		suffix = "netmasked";
		break;

	case FRI_PEERADDR :
		suffix = "peer";
		break;

	case FRI_LOOKUP :
		suffix = NULL;
		printlookup(base, (i6addr_t *)addr, (i6addr_t *)mask);
		break;

	case FRI_NONE :
	case FRI_NORMAL :
		printhostmask(family, addr, mask);
		suffix = NULL;
		break;
	case FRI_RANGE :
		printhost(family, addr);
		putchar('-');
		printhost(family, mask);
		suffix = NULL;
		break;
	case FRI_SPLIT :
		printhost(family, addr);
		putchar(',');
		printhost(family, mask);
		suffix = NULL;
		break;
	default :
		PRINTF("<%d>", type);
		printmask(family, mask);
		suffix = NULL;
		break;
	}

	if (suffix != NULL) {
		PRINTF("%s/%s", base + ifidx, suffix);
	}
}