xref: /illumos-gate/usr/src/cmd/ipf/lib/printaddr.c (revision 1a2d662a91cee3bf82f41cd47c7ae6f3825d9db2)
1 /*
2  * Copyright (C) 2005 by Darren Reed.
3  *
4  * See the IPFILTER.LICENCE file for details on licencing.
5  *
6  */
7 
8 #include "ipf.h"
9 
10 
11 void printaddr(v, type, ifname, addr, mask)
12 int v, type;
13 char *ifname;
14 u_32_t *addr, *mask;
15 {
16 	char *suffix;
17 
18 	switch (type)
19 	{
20 	case FRI_BROADCAST :
21 		suffix = "/bcast";
22 		break;
23 
24 	case FRI_DYNAMIC :
25 		printf("%s", ifname);
26 		printmask(v, mask);
27 		suffix = NULL;
28 		break;
29 
30 	case FRI_NETWORK :
31 		suffix = "/net";
32 		break;
33 
34 	case FRI_NETMASKED :
35 		suffix = "/netmasked";
36 		break;
37 
38 	case FRI_PEERADDR :
39 		suffix = "/peer";
40 		break;
41 
42 	case FRI_LOOKUP :
43 		suffix = NULL;
44 		printlookup((i6addr_t *)addr, (i6addr_t *)mask);
45 		break;
46 
47 	case FRI_NORMAL :
48 		printhostmask(v, addr, mask);
49 		suffix = NULL;
50 		break;
51 	default :
52 		printf("<%d>", type);
53 		printmask(v, mask);
54 		suffix = NULL;
55 		break;
56 	}
57 
58 	if (suffix != NULL) {
59 		printf("%s/%s", ifname, suffix);
60 	}
61 }
62