comparison usr/src/cmd/ipf/lib/common/getnattype.c @ 0:c9caec207d52 b86

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