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 #include "ipf.h" 13 #include "kmem.h" 14 15 #if !defined(lint) 16 static const char rcsid[] = "@(#)$Id: getnattype.c,v 1.3 2004/01/17 17:26:07 darrenr Exp $"; 17 #endif 18 19 20 /* 21 * Get a nat filter type given its kernel address. 22 */ getnattype(nat,alive)23char *getnattype(nat, alive) 24 nat_t *nat; 25 int alive; 26 { 27 static char unknownbuf[20]; 28 ipnat_t *ipn, ipnatbuff; 29 char *which; 30 int type; 31 32 if (!nat) 33 return "???"; 34 if (alive) { 35 type = nat->nat_redir; 36 } else { 37 ipn = nat->nat_ptr; 38 if (kmemcpy((char *)&ipnatbuff, (long)ipn, sizeof(ipnatbuff))) 39 return "!!!"; 40 type = ipnatbuff.in_redir; 41 } 42 43 switch (type) 44 { 45 case NAT_MAP : 46 which = "MAP"; 47 break; 48 case NAT_MAPBLK : 49 which = "MAP-BLOCK"; 50 break; 51 case NAT_REDIRECT : 52 which = "RDR"; 53 break; 54 case NAT_BIMAP : 55 which = "BIMAP"; 56 break; 57 default : 58 sprintf(unknownbuf, "unknown(%04x)", type & 0xffffffff); 59 which = unknownbuf; 60 break; 61 } 62 return which; 63 } 64