1 /* 2 * Copyright (C) 1993-2001 by Darren Reed. 3 * 4 * See the IPFILTER.LICENCE file for details on licencing. 5 * 6 * Added redirect stuff and a variety of bug fixes. (mcn@EnGarde.com) 7 * 8 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 9 * Use is subject to license terms. 10 */ 11 12 #pragma ident "%Z%%M% %I% %E% SMI" 13 14 #include "ipf.h" 15 #include "kmem.h" 16 17 #if !defined(lint) 18 static const char rcsid[] = "@(#)$Id: getnattype.c,v 1.3 2004/01/17 17:26:07 darrenr Exp $"; 19 #endif 20 21 22 /* 23 * Get a nat filter type given its kernel address. 24 */ getnattype(nat,alive)25char *getnattype(nat, alive) 26 nat_t *nat; 27 int alive; 28 { 29 static char unknownbuf[20]; 30 ipnat_t *ipn, ipnatbuff; 31 char *which; 32 int type; 33 34 if (!nat) 35 return "???"; 36 if (alive) { 37 type = nat->nat_redir; 38 } else { 39 ipn = nat->nat_ptr; 40 if (kmemcpy((char *)&ipnatbuff, (long)ipn, sizeof(ipnatbuff))) 41 return "!!!"; 42 type = ipnatbuff.in_redir; 43 } 44 45 switch (type) 46 { 47 case NAT_MAP : 48 which = "MAP"; 49 break; 50 case NAT_MAPBLK : 51 which = "MAP-BLOCK"; 52 break; 53 case NAT_REDIRECT : 54 which = "RDR"; 55 break; 56 case NAT_BIMAP : 57 which = "BIMAP"; 58 break; 59 default : 60 sprintf(unknownbuf, "unknown(%04x)", type & 0xffffffff); 61 which = unknownbuf; 62 break; 63 } 64 return which; 65 } 66