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