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