getnattype.c revision 153881
1/* $FreeBSD: head/contrib/ipfilter/lib/getnattype.c 153881 2005-12-30 11:52:26Z guido $ */ 2 3/* 4 * Copyright (C) 1993-2001 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 2004/01/17 17:26:07 darrenr Exp $"; 15#endif 16 17 18/* 19 * Get a nat filter type given its kernel address. 20 */ 21char *getnattype(ipnat) 22ipnat_t *ipnat; 23{ 24 static char unknownbuf[20]; 25 ipnat_t ipnatbuff; 26 char *which; 27 28 if (!ipnat) 29 return "???"; 30 if (kmemcpy((char *)&ipnatbuff, (long)ipnat, sizeof(ipnatbuff))) 31 return "!!!"; 32 33 switch (ipnatbuff.in_redir) 34 { 35 case NAT_MAP : 36 which = "MAP"; 37 break; 38 case NAT_MAPBLK : 39 which = "MAP-BLOCK"; 40 break; 41 case NAT_REDIRECT : 42 which = "RDR"; 43 break; 44 case NAT_BIMAP : 45 which = "BIMAP"; 46 break; 47 default : 48 sprintf(unknownbuf, "unknown(%04x)", 49 ipnatbuff.in_redir & 0xffffffff); 50 which = unknownbuf; 51 break; 52 } 53 return which; 54} 55