1 2 /* 3 * Copyright (C) 2012 by Darren Reed. 4 * 5 * See the IPFILTER.LICENCE file for details on licencing. 6 * 7 * Added redirect stuff and a variety of bug fixes. (mcn@EnGarde.com) 8 */ 9 #include "ipf.h" 10 #include "kmem.h" 11 12 13 14 /* 15 * Get a nat filter type given its kernel address. 16 */ 17 char * getnattype(nat_t * nat)18getnattype(nat_t *nat) 19 { 20 static char unknownbuf[20]; 21 char *which; 22 23 if (!nat) 24 return ("???"); 25 26 switch (nat->nat_redir) 27 { 28 case NAT_MAP : 29 which = "MAP"; 30 break; 31 case NAT_MAPBLK : 32 which = "MAP-BLOCK"; 33 break; 34 case NAT_REDIRECT : 35 which = "RDR"; 36 break; 37 case NAT_MAP|NAT_REWRITE : 38 which = "RWR-MAP"; 39 break; 40 case NAT_REDIRECT|NAT_REWRITE : 41 which = "RWR-RDR"; 42 break; 43 case NAT_BIMAP : 44 which = "BIMAP"; 45 break; 46 case NAT_REDIRECT|NAT_DIVERTUDP : 47 which = "DIV-RDR"; 48 break; 49 case NAT_MAP|NAT_DIVERTUDP : 50 which = "DIV-MAP"; 51 break; 52 case NAT_REDIRECT|NAT_ENCAP : 53 which = "ENC-RDR"; 54 break; 55 case NAT_MAP|NAT_ENCAP : 56 which = "ENC-MAP"; 57 break; 58 default : 59 snprintf(unknownbuf, sizeof(unknownbuf), "unknown(%04x)", 60 nat->nat_redir & 0xffffffff); 61 which = unknownbuf; 62 break; 63 } 64 return (which); 65 } 66