xref: /netbsd-src/external/bsd/ipf/dist/lib/printlookup.c (revision 13885a665959c62f13a82b3caedf986eaa17aa31)
1 /*	$NetBSD: printlookup.c,v 1.2 2012/07/22 14:27:36 darrenr Exp $	*/
2 
3 /*
4  * Copyright (C) 2012 by Darren Reed.
5  *
6  * See the IPFILTER.LICENCE file for details on licencing.
7  *
8  * Id: printlookup.c,v 1.1.1.2 2012/07/22 13:44:41 darrenr Exp $
9  */
10 
11 #include "ipf.h"
12 
13 
14 void
printlookup(base,addr,mask)15 printlookup(base, addr, mask)
16 	char *base;
17 	i6addr_t *addr, *mask;
18 {
19 	char name[32];
20 
21 	switch (addr->iplookuptype)
22 	{
23 	case IPLT_POOL :
24 		PRINTF("pool/");
25 		break;
26 	case IPLT_HASH :
27 		PRINTF("hash/");
28 		break;
29 	case IPLT_DSTLIST :
30 		PRINTF("dstlist/");
31 		break;
32 	default :
33 		PRINTF("lookup(%x)=", addr->iplookuptype);
34 		break;
35 	}
36 
37 	if (addr->iplookupsubtype == 0)
38 		PRINTF("%u", addr->iplookupnum);
39 	else if (addr->iplookupsubtype == 1) {
40 		strncpy(name, base + addr->iplookupname, sizeof(name));
41 		name[sizeof(name) - 1] = '\0';
42 		PRINTF("%s", name);
43 	}
44 }
45