1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright (C) 1993-2001 by Darren Reed.
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * See the IPFILTER.LICENCE file for details on licencing.
5*7c478bd9Sstevel@tonic-gate  *
6*7c478bd9Sstevel@tonic-gate  * Added redirect stuff and a variety of bug fixes. (mcn@EnGarde.com)
7*7c478bd9Sstevel@tonic-gate  */
8*7c478bd9Sstevel@tonic-gate #include "ipf.h"
9*7c478bd9Sstevel@tonic-gate #include "kmem.h"
10*7c478bd9Sstevel@tonic-gate 
11*7c478bd9Sstevel@tonic-gate #if !defined(lint)
12*7c478bd9Sstevel@tonic-gate static const char rcsid[] = "@(#)$Id: getnattype.c,v 1.2 2002/01/28 06:50:46 darrenr Exp $";
13*7c478bd9Sstevel@tonic-gate #endif
14*7c478bd9Sstevel@tonic-gate 
15*7c478bd9Sstevel@tonic-gate 
16*7c478bd9Sstevel@tonic-gate /*
17*7c478bd9Sstevel@tonic-gate  * Get a nat filter type given its kernel address.
18*7c478bd9Sstevel@tonic-gate  */
19*7c478bd9Sstevel@tonic-gate char *getnattype(ipnat)
20*7c478bd9Sstevel@tonic-gate ipnat_t *ipnat;
21*7c478bd9Sstevel@tonic-gate {
22*7c478bd9Sstevel@tonic-gate 	static char unknownbuf[20];
23*7c478bd9Sstevel@tonic-gate 	ipnat_t ipnatbuff;
24*7c478bd9Sstevel@tonic-gate 	char *which;
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate 	if (!ipnat || (ipnat && kmemcpy((char *)&ipnatbuff, (long)ipnat,
27*7c478bd9Sstevel@tonic-gate 					sizeof(ipnatbuff))))
28*7c478bd9Sstevel@tonic-gate 		return "???";
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate 	switch (ipnatbuff.in_redir)
31*7c478bd9Sstevel@tonic-gate 	{
32*7c478bd9Sstevel@tonic-gate 	case NAT_MAP :
33*7c478bd9Sstevel@tonic-gate 		which = "MAP";
34*7c478bd9Sstevel@tonic-gate 		break;
35*7c478bd9Sstevel@tonic-gate 	case NAT_MAPBLK :
36*7c478bd9Sstevel@tonic-gate 		which = "MAP-BLOCK";
37*7c478bd9Sstevel@tonic-gate 		break;
38*7c478bd9Sstevel@tonic-gate 	case NAT_REDIRECT :
39*7c478bd9Sstevel@tonic-gate 		which = "RDR";
40*7c478bd9Sstevel@tonic-gate 		break;
41*7c478bd9Sstevel@tonic-gate 	case NAT_BIMAP :
42*7c478bd9Sstevel@tonic-gate 		which = "BIMAP";
43*7c478bd9Sstevel@tonic-gate 		break;
44*7c478bd9Sstevel@tonic-gate 	default :
45*7c478bd9Sstevel@tonic-gate 		sprintf(unknownbuf, "unknown(%04x)",
46*7c478bd9Sstevel@tonic-gate 			ipnatbuff.in_redir & 0xffffffff);
47*7c478bd9Sstevel@tonic-gate 		which = unknownbuf;
48*7c478bd9Sstevel@tonic-gate 		break;
49*7c478bd9Sstevel@tonic-gate 	}
50*7c478bd9Sstevel@tonic-gate 	return which;
51*7c478bd9Sstevel@tonic-gate }
52