xref: /freebsd/sbin/ipf/libipf/printlookup.c (revision efeb8bffe34422937c7f8df836afb5b817366d16)
141edb306SCy Schubert /*
241edb306SCy Schubert  * Copyright (C) 2012 by Darren Reed.
341edb306SCy Schubert  *
441edb306SCy Schubert  * See the IPFILTER.LICENCE file for details on licencing.
541edb306SCy Schubert  *
641edb306SCy Schubert  * $Id$
741edb306SCy Schubert  */
841edb306SCy Schubert 
941edb306SCy Schubert #include "ipf.h"
1041edb306SCy Schubert 
1141edb306SCy Schubert 
1241edb306SCy Schubert void
printlookup(char * base,i6addr_t * addr,i6addr_t * mask)13*efeb8bffSCy Schubert printlookup(char *base, i6addr_t *addr, i6addr_t *mask)
1441edb306SCy Schubert {
1541edb306SCy Schubert 	char name[32];
1641edb306SCy Schubert 
1741edb306SCy Schubert 	switch (addr->iplookuptype)
1841edb306SCy Schubert 	{
1941edb306SCy Schubert 	case IPLT_POOL :
2041edb306SCy Schubert 		PRINTF("pool/");
2141edb306SCy Schubert 		break;
2241edb306SCy Schubert 	case IPLT_HASH :
2341edb306SCy Schubert 		PRINTF("hash/");
2441edb306SCy Schubert 		break;
2541edb306SCy Schubert 	case IPLT_DSTLIST :
2641edb306SCy Schubert 		PRINTF("dstlist/");
2741edb306SCy Schubert 		break;
2841edb306SCy Schubert 	default :
2941edb306SCy Schubert 		PRINTF("lookup(%x)=", addr->iplookuptype);
3041edb306SCy Schubert 		break;
3141edb306SCy Schubert 	}
3241edb306SCy Schubert 
3341edb306SCy Schubert 	if (addr->iplookupsubtype == 0)
3441edb306SCy Schubert 		PRINTF("%u", addr->iplookupnum);
3541edb306SCy Schubert 	else if (addr->iplookupsubtype == 1) {
3641edb306SCy Schubert 		strncpy(name, base + addr->iplookupname, sizeof(name));
3741edb306SCy Schubert 		name[sizeof(name) - 1] = '\0';
3841edb306SCy Schubert 		PRINTF("%s", name);
3941edb306SCy Schubert 	}
4041edb306SCy Schubert }
41