Sync usage with man page.
[netbsd-mini2440.git] / dist / ipf / lib / getnattype.c
blobd2053ea7b162e266f240b2daa72cb8406f5a4fa5
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2002-2004 by Darren Reed.
6 * See the IPFILTER.LICENCE file for details on licencing.
8 * Added redirect stuff and a variety of bug fixes. (mcn@EnGarde.com)
9 */
10 #include "ipf.h"
11 #include "kmem.h"
13 #if !defined(lint)
14 static const char rcsid[] = "@(#)Id: getnattype.c,v 1.3.2.2 2006/07/14 06:12:24 darrenr Exp";
15 #endif
19 * Get a nat filter type given its kernel address.
21 char *getnattype(nat, alive)
22 nat_t *nat;
23 int alive;
25 static char unknownbuf[20];
26 ipnat_t *ipn, ipnat;
27 char *which;
28 int type;
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;
41 switch (type)
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;
60 return which;