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